import { createSlice,createAsyncThunk  } from '@reduxjs/toolkit';
import {getById} from '../../services/classify';

export const fetchClassify = createAsyncThunk('classify/fetchClassify',async (id) => {
    let {data} = await getById(id);
    return data;
});
const classifySlice = createSlice({
    name: "classify",
    initialState:{
        updateVisible:false,
        classify:{}
    },
    reducers:{
        setUpdateVisible(state,action){
            state.updateVisible = action.payload;
        }
      
    },
    extraReducers(builder) {
        builder.addCase(fetchClassify.fulfilled, (state, action) => {
            state.classify = action.payload;
        })
    }
});
export const {setUpdateVisible} = classifySlice.actions;
export default classifySlice.reducer;